package introduce

import (
	"hotel_Manager_Api/model/dbModel"
	"hotel_Manager_Api/model/dbEngin"
	"github.com/martini-contrib/encoder"
)

func EditIntroduce(introduce dbModel.HotelIntroduce) (int,error) {
	db:=dbEngin.GetEnging();
	sql := "INSERT INTO `hotel_introduce`(id,introduce) values (?,?) ON DUPLICATE KEY UPDATE introduce=?"
	_,err :=db.Exec(sql,1,introduce.Introduce,introduce.Introduce)
	if(err!=nil){
		return 500,err;
	}
	return 200,nil
}

func GetIntroduce(enc encoder.Encoder)([]byte,error) {
	introduce := new(dbModel.HotelIntroduce)
	dbEngin.GetEnging().Id(1).Get(introduce)
	return encoder.Must(enc.Encode(introduce)),nil;
}